package com.xuwang.controller;

import com.xuwang.pojo.Inventory;
import com.xuwang.service.impl.InventoryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 库存表(Inventory)表控制层
 *
 * @author abaaba
 * @since 2021-09-18 09:10:59
 * @version 1.0
 */
@RestController
@RequestMapping("/inventory")
@Api(value = "库存表(Inventory)管理",tags = "库存表(Inventory)管理接口API")
@ApiResponses({
        @ApiResponse(code=400,message="请求参数不完整或者错误"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=405,message="请求方式不正确，比如后台接收是post，但前端请求的是get"),
        @ApiResponse(code=406,message="页面地址和接口名冲突"),
        @ApiResponse(code=415,message="请求格式不正确，前端可能没有把请求头修改为json，也可能前端请求的json对象没有转换为字符串"),
        @ApiResponse(code=500,message="后台服务逻辑错误")
})
public class InventoryController {
    /**
     * 服务对象
     */
    @Resource
    private InventoryServiceImpl inventoryServiceImpl;

    /**
     * 通过主键查询单条数据
     * @param index  需要查询的页码
     * @param name  模糊查询的内容
     * @return 单条数据
     */
    @RequestMapping(value = "/selectForPageZF", method = RequestMethod.GET)
    @ApiOperation(value = "列表查询分页接口",notes = "列表查询分页接口",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "index",value = "第几页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "page",value = "每页数量",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "type",value = "查看的类型（1,2,3）",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "batchNo",value = "批号",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "name",value = "对应名称",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "companyName",value = "公司名称",paramType = "query",dataType = "String",required = false)
    })
    public Map<String, Object> selectForPageZF(@RequestParam(name = "index") int index,
                                             @RequestParam(name = "page") int page,
                                             Integer type, String batchNo, String name, String companyName
                                            ) {
        return this.inventoryServiceImpl.selectForPageZF(index, page,type,batchNo,name,companyName);
    }
    /**
     * 通过主键查询单条数据
     * @param index  需要查询的页码
     * @param name  模糊查询的内容
     * @return 单条数据
     */
    @RequestMapping(value = "/selectForPageQY", method = RequestMethod.GET)
    @ApiOperation(value = "列表查询分页接口",notes = "列表查询分页接口",httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "index",value = "第几页",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "page",value = "每页数量",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "type",value = "查看的类型（1,2,3）",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "batchNo",value = "批号",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "name",value = "对应名称",paramType = "query",dataType = "String",required = false),
//            @ApiImplicitParam(name = "companyName",value = "公司名称",paramType = "query",dataType = "String",required = false)
    })
    public Map<String, Object> selectForPageQY(@RequestParam(name = "index") int index,
                                               @RequestParam(name = "page") int page,
                                               Integer type, String batchNo, String name,
                                               @Autowired HttpServletRequest request) {
        return this.inventoryServiceImpl.selectForPageQY(index, page,type,batchNo,name,request);
    }
    
    /**
     * 直接从别人库存进货的时候，查看其他企业的库存，根据名字返回批号，货物名、库存量、对应库存企业。
     * @return 返回所有数据
     */
    @RequestMapping(value = "/selectAllByName", method = RequestMethod.GET)
    @ApiOperation(value = "直接从别人库存进货的时候，查看其他企业的库存，根据名字返回批号，货物名、库存量、对应库存企业。",
            notes = "直接从别人库存进货的时候，查看其他企业的库存，根据名字返回批号，货物名、库存量、对应库存企业。",httpMethod = "GET")
    @ApiImplicitParam(name = "name",value = "name",paramType = "query",dataType = "String",required = true)
    public Map<String, Object> selectAllByName(@RequestParam(name = "name") String name) {
        return this.inventoryServiceImpl.selectAllByName(name);
    }


    /**
     * 直接从别人库存进货的时候，查看其他企业的库存，根据名字返回批号，货物名、库存量、对应库存企业。
     * @return 返回所有数据
     */
    @RequestMapping(value = "/selectBatchByMyCompany", method = RequestMethod.GET)
    @ApiOperation(value = "查询本公司存有菜品批号",
            notes = "查询本公司存有菜品批号",httpMethod = "GET")
    public Map<String, Object> selectBatchByMyCompany(@Autowired HttpServletRequest request) {
        return this.inventoryServiceImpl.selectBatchByMyCompany(1,request);
    }
    @RequestMapping(value = "/selectBatchALLByMyCompany", method = RequestMethod.GET)
    @ApiOperation(value = "查询本公司存有所有批号",
            notes = "查询本公司存有所有批号",httpMethod = "GET")
    public Map<String, Object> selectBatchALLByMyCompany(@Autowired HttpServletRequest request) {
        return this.inventoryServiceImpl.selectBatchByMyCompany(2,request);
    }


    /**
     * 都不满意的话直接去call别人电话，让他们生产，传入需要的货物名字，返回公司和电话
     * @return 返回所有数据
     */
    @RequestMapping(value = "/selectProductionCompanyByName", method = RequestMethod.GET)
    @ApiOperation(value = "都不满意的话直接去call别人电话，让他们生产，传入需要的货物名字，返回公司和电话",
            notes = "都不满意的话直接去call别人电话，让他们生产，传入需要的货物名字，返回公司和电话",httpMethod = "GET")
    @ApiImplicitParam(name = "name",value = "name",paramType = "query",dataType = "String",required = true)
    public Map<String, Object> selectProductionCompanyByName(@RequestParam(name = "name") String name) {
        return this.inventoryServiceImpl.selectProductionCompanyByName(name);
    }
    /**
     * 查询本公司拥有的东西
     * @return 返回所有数据
     */
    @RequestMapping(value = "/selectProductionAllByName", method = RequestMethod.GET)
    @ApiOperation(value = "查询本公司拥有的东西",
            notes = "查询本公司拥有的东西",httpMethod = "GET")
    @ApiImplicitParam(name = "name",value = "name",paramType = "query",dataType = "String",required = true)
    public Map<String, Object> selectProductionAllByName(@RequestParam(name = "name") String name,@Autowired HttpServletRequest request ) {
        return this.inventoryServiceImpl.selectProductionAllByName(name,request);
    }
    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @RequestMapping(value = "/selectById", method = RequestMethod.GET)
    @ApiOperation(value = "通过主键查询一个**的接口",notes = "通过主键查询一个**的接口",httpMethod = "GET")
    public Map<String, Object> selectById(Integer id) {
        return this.inventoryServiceImpl.selectById(id);
    }

}